<template>
  <div>

    <el-form
      :inline="true"
      label-position="right"
      label-width="130px"
      size="small"
    >

      <el-row>
        <el-col :span="8">
          <el-form-item label="产品通用名：">
            {{ datas.productPopularName }}
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="商品名：">
            {{ datas.productName }}
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="包装规格：">
            {{ datas.packSpecs }}
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="生产厂家：">
            {{ datas.producer }}
          </el-form-item>
        </el-col>

        <!--                <el-col :span="8">-->
        <!--                    <el-form-item :label="agent.agentType == 'agent' ? '代理属性:' : '兼职属性:'">-->
        <!--                        {{getLabel(agent.agentType , datas.agentAttribute) }}-->
        <!--                    </el-form-item>-->
        <!--                </el-col>-->

        <el-col :span="8">
          <el-form-item label="代理地区：">
            <area-list-view :areas="datas.region" />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="交易价：">
            <div style="display: flex;align-items: center">
              <span>{{ datas.tradePrice }}元/{{ getLabel('sell_unit',datas.sellUnit) }}</span>

              <span
                v-if="(datas.processDefinitionKey == 'agentProductChangePrice' || datas.processDefinitionKey == 'agentPersonProductChangePrice') && datas.flowStatus == 'DOING'"
                class="doing-status"
              >变更中</span>
              <el-icon
                v-else-if="datas.agentProductStatus == 2"
                color="#409EFC"
                :size="20"
                style="padding-left: 10px"
                @click="onEdit"
              >
                <edit />
              </el-icon>
            </div>

          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="可营销终端：">
            {{ getLabel('app_mode',datas.terminalType) }}
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="最低销量：">
            <div v-if="datas.minSale">
<!--              {{ datas.minSale }}{{ getLabel('sell_unit',datas.sellUnit) }}/{{ getLabel('sell_num_unit',datas.minSaleUnit) }}-->

              <span v-if="datas.isIncrease == 2">首年{{datas.minSale}}{{getLabel('sell_unit',datas.sellUnit)}},每年递增{{datas.increaseNum}}%</span>
              <span v-else>{{datas.minSale}}{{getLabel('sell_unit',datas.sellUnit)}}/{{ getLabel('sell_num_unit',datas.minSaleUnit) }}</span>
            </div>
            <div v-else>未设置</div>

          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="销量保证金：">

            <div v-if="datas.minSalePromise">
              {{ datas.minSalePromise }}元
            </div>
            <div v-else>未设置</div>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="代理期限至：">
            {{ dateFormat('yyyy-mm-dd',datas.agentEndTime) }}
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="负责营销职员：">
            {{ datas.headName }}
          </el-form-item>
        </el-col>

<!--        <el-col :span="8">-->
<!--          <el-form-item label="代理协议名称:">-->
<!--            {{ datas.abstract }}-->
<!--          </el-form-item>-->
<!--        </el-col>-->

        <el-col :span="8">
          <el-form-item label="创建人：">
            {{ datas.creatorName }}
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="创建时间：">
            {{ dateFormat('yyyy-mm-dd HH:MM',datas.createdAt) }}
          </el-form-item>
        </el-col>

      </el-row>

      <el-row>

        <el-col :span="24">
          <el-form-item label="其他约定：">
            {{ datas.remark }}
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>

    <changePriceDialog
      ref="refChange"
      @sucess="sucess"
    />

  </div>
</template>

<script>
import {Edit} from '@element-plus/icons'
import {defineComponent,defineAsyncComponent, reactive, toRefs} from 'vue'

export default defineComponent({
  name: 'AgreementInfoView',
  components: {
      Edit,
      changePriceDialog :defineAsyncComponent(()=>import('./changePriceDialog.vue'))
  },
  props: {
    datas: {
      type: Object,
      default: {},
    },
    agent: {
      type: Object,
      default: {},
    },
  },
  setup(props, { emit }) {
    var data = reactive({
      refChange: null,
    })

    const onEdit = () => {
      data.refChange.openDialog(props.datas)
    }

    const sucess = () => {
      emit('onUpdate')
    }

    return {
      ...toRefs(data),

      onEdit,
      sucess,
    }
  },
})
</script>

<style lang="scss" scoped>
    @import "@/style/basics.scss";
    .doing-status{
        margin-left: 10px;
        color: $assist-color;
    }
</style>
